package com.example.networkchangedemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.networkchangedemo.R;
import com.example.networkchangedemo.model.VideoDetailModel;

import java.util.List;

/**
 * @author: njb
 * @date: 2022/3/15 11:41
 * @desc: 描述
 */
public class FullVideoDetailAdapter extends RecyclerView.Adapter<FullVideoDetailAdapter.MyViewHolder> {
    private Context context;
    private List<VideoDetailModel> mList;

    public FullVideoDetailAdapter(Context context, List<VideoDetailModel> list){
        this.context = context;
        this.mList = list;
    }


    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
       View view = LayoutInflater.from(context).inflate(R.layout.item_full_video_column,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tvTime.setText(mList.get(position).getPoint());
        holder.tvContent.setText(mList.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{
        TextView tvTime;
        TextView tvContent;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            tvTime = itemView.findViewById(R.id.tv_full_time);
            tvContent = itemView.findViewById(R.id.tv_full_content);
        }
    }
}
